package com.settlement.system.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.settlement.system.common.result.PageResult;
import com.settlement.system.common.result.Result;
import com.settlement.system.model.entity.SysDoneAudit;
import com.settlement.system.model.query.AuditPageQuery;
import com.settlement.system.model.vo.AuditVo;
import com.settlement.system.service.SysAuditService;
import com.settlement.system.service.SysDoneAuditService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 个人已办或归档核销表 前端控制器
 * </p>
 *
 * @author huangrensen
 * @since 2023-08-30
 */
@Tag(name = "个人已办或归档核销表")
@RestController
@RequestMapping("/api/v1/doneAudit")
@RequiredArgsConstructor
public class SysDoneAuditController {
    private final SysDoneAuditService sysDoneAuditService;

    @Operation(summary = "个人已办或归档核销表分页列表", security = {@SecurityRequirement(name = "Authorization")})
    @GetMapping("/page")
    public PageResult<SysDoneAudit> getPage(@ParameterObject AuditPageQuery queryParams) {
        Page<SysDoneAudit> result = sysDoneAuditService.getPage(queryParams);
        return PageResult.success(result);
    }

    @Operation(summary = "获取详情", security = {@SecurityRequirement(name = "Authorization")})
    @GetMapping(value = "/{auditId}")
    public Result<AuditVo> getAuditForm(@Parameter(description = "核销单ID") @PathVariable String auditId) {
        AuditVo formData = sysDoneAuditService.getAuditForm(auditId);
        return Result.success(formData);
    }

    @Operation(summary = "获取标准订单详情", security = {@SecurityRequirement(name = "Authorization")})
    @GetMapping(value = "/order/{doneId}")
    public Result<?> getOrderDetail(@Parameter(description = "关联单号") @PathVariable String doneId) {
        return Result.success(sysDoneAuditService.getOrderDetailList(doneId));
    }

    @Operation(summary = "获取标准账单详情", security = {@SecurityRequirement(name = "Authorization")})
    @GetMapping(value = "/bill/{doneId}")
    public Result<?> getBillDetail(@Parameter(description = "关联单号") @PathVariable String doneId) {
        return Result.success(sysDoneAuditService.getBillDetail(doneId));
    }
}
